public void changeColor(double redFactor, double greenFactor, double blueFactor) { // change the values this.changeRed(redFactor); this.changeGreen(greenFactor); this.changeBlue(blueFactor); }//End changeColor public void changeRed(double factor) { Pixel[] pixelArray = this.getPixels(); int value = 0; //loop through the array of pixels; pixelObj is a variable pointing //the current pixel for (Pixel pixelObj : pixelArray) { // get the red value value = pixelObj.getRed(); //set the red value to double its current value pixelObj.setRed((int)(value*factor)); } }//End ChangeRed public void changeGreen(double factor) { Pixel[] pixelArray = this.getPixels(); int value = 0; //loop through the array of pixels; pixelObj is a variable pointing //the current pixel for (Pixel pixelObj : pixelArray) { // get the green value value = pixelObj.getGreen(); //set the green value to double its current value pixelObj.setGreen((int)(value*factor)); } }//End ChangeGreen public void changeBlue(double factor) { Pixel[] pixelArray = this.getPixels(); int value = 0; //loop through the array of pixels; pixelObj is a variable pointing //the current pixel for (Pixel pixelObj : pixelArray) { // get the blue value value = pixelObj.getBlue(); //set the blue value to double its current value pixelObj.setBlue((int)(value*factor)); } }//End ChangeBlue public void mirrorHoriz() { //This method mirrors horizontally Pixel topPixel = null; Pixel bottomPixel = null; int arrayHeight = this.getHeight()-1; int mirrorPoint = this.getHeight()/2; //loop through every column of pixels for (int x=0; x < this.getWidth(); x++) { //loop through the rows until you reach the mirror point for (int y = 0; y < mirrorPoint; y++) { // get the pixel to copy topPixel = this.getPixel(x,y); //get the pixel to change bottomPixel = this.getPixel(x,arrayHeight-y); //copy the color from one to the other bottomPixel.setColor(topPixel.getColor()); } } } //end mirrorHoriz public void createCollage(Picture source1Picture, Picture source2Picture) { //variables to use as parameters in the copy method int targetX=0; int targetY=0; int maxHeight = Math.max(source1Picture.getHeight(), source2Picture.getHeight()); int targetHeight = this.getHeight(); int targetWidth = this.getWidth(); int xCounter = this.getWidth()/(source1Picture.getWidth()+source2Picture.getWidth()); int yCounter = this.getHeight()/(maxHeight); //I'm using this counter concept because I couldn't get the loop //to work using checks on the target height and width vs what it would //be after adding the width or height of the next two pictures for (int y = 0; y < yCounter; y++) { for (int x=0; x < xCounter; x++) { // change the color for the pictures //if this is the first or an even row, change red and blue; otherwise, change green if ((y==0 || y%2==0) && y!=1) { source1Picture.changeBlue(.10); source2Picture.changeRed(.10); } else { source1Picture.changeGreen(.50); source2Picture.changeGreen(.50); } //copy the first picture; copy the second if space allows this.copy(source1Picture,0,0, source1Picture.getWidth(), source1Picture.getHeight(), targetX,targetY); targetX=targetX+source1Picture.getWidth(); if (targetWidth > (targetX + source2Picture.getWidth())) { // copy source2Picture this.copy(source2Picture,0,0, source2Picture.getWidth(), source2Picture.getHeight(), targetX,targetY); } targetX=targetX+source2Picture.getWidth();; } targetY = targetY+maxHeight; targetX=0; } }//end createCollage public static void main(String[] args) { //Choose the pictures to copy then the target Picture pict1 = new Picture(FileChooser.pickAFile()); Picture pict2 = new Picture(FileChooser.pickAFile()); Picture blank = new Picture(FileChooser.pickAFile()); //choose the picture blank.createCollage(pict1,pict2); blank.mirrorHoriz(); blank.write(FileChooser.getMediaPath("DH-BegJavaHmwk6-25-08.jpg")); blank.explore();//show the picture }